package test.br.com.lh.urabuilder.command
{
	import br.com.lh.urabuilder.command.NewUraCommand;
	import br.com.lh.urabuilder.event.NewUraEvent;
	import br.com.lh.urabuilder.model.UraModelLocator;
	
	import flexunit.framework.TestCase;
	import flexunit.framework.TestSuite;
	
	import mock.br.com.lh.urabuilder.business.MockedSelectableComponentManager;
	import mock.br.com.lh.urabuilder.business.MockedViewManager;
	import mock.br.com.lh.urabuilder.business.MockedXmlManager;
	import mock.br.com.lh.urabuilder.view.properties.MockedUraPropertiesPanel;
	
	import mx.containers.Canvas;

	public class NewUraCommandTest extends TestCase
	{
		public function NewUraCommandTest(methodName:String=null)
		{
			super(methodName);
		}
		
		public static function suite():TestSuite{
			var ts:TestSuite = new TestSuite();
			ts.addTest(new NewUraCommandTest("shouldCleanCanvasAndProperties"));
			return ts;
		}
		
		public function shouldCleanCanvasAndProperties():void{
			var newUraEvent:NewUraEvent = new NewUraEvent();
			var newUraCommand:NewUraCommand = new NewUraCommand();
			var mockedXmlManager:MockedXmlManager = new MockedXmlManager();
			var mockedViewManager:MockedViewManager = new MockedViewManager();
			var mockedSelectableComponentManager:MockedSelectableComponentManager = new MockedSelectableComponentManager();
			var mockedUraPropertiesPanel:MockedUraPropertiesPanel = new MockedUraPropertiesPanel();
			var uraModelLocator:UraModelLocator = UraModelLocator.getInstance(new Canvas());
			uraModelLocator.viewManager = mockedViewManager;
			uraModelLocator.xmlManager = mockedXmlManager;
			uraModelLocator.selectableComponents = mockedSelectableComponentManager;
			uraModelLocator.uraPropertiesForm = mockedUraPropertiesPanel; 
			mockedViewManager.expects("clearUra");
			mockedXmlManager.expects("clearUra");
			mockedSelectableComponentManager.expects("clearUra");
			mockedUraPropertiesPanel.expects("clearUra");
			newUraCommand.execute(newUraEvent);
			assertTrue(mockedViewManager.errorMessage(),mockedViewManager.success());
			assertTrue(mockedXmlManager.errorMessage(),mockedXmlManager.success());
			assertTrue(mockedSelectableComponentManager.errorMessage(),mockedSelectableComponentManager.success());
			assertTrue(mockedUraPropertiesPanel.errorMessage(),mockedUraPropertiesPanel.success());
		}
		
		
	}
}